/**
 * File: InvalidateNotActiveNodes.java
 * Created by: mhaimel
 * Created on: Mar 30, 2010
 * CVS:  $Id: InvalidateNotActiveNodes.java 1.0 Mar 30, 2010 9:07:23 AM mhaimel Exp $
 */
package uk.ac.ebi.curtain.model.graph.curtain.filter;

import uk.ac.ebi.curtain.model.graph.Arc;
import uk.ac.ebi.curtain.model.graph.Graph;
import uk.ac.ebi.curtain.model.graph.GraphAccess.TouchEach;
import uk.ac.ebi.curtain.model.graph.curtain.ContigInfo;
import uk.ac.ebi.curtain.model.graph.curtain.ReadWrapper;

/**
 * If one of the nodes (left or right) are attached to a not active node, remove Arc
 * 
 * @author mhaimel
 *
 */
public class InvalidateNotActiveNodes implements TouchEach<Arc<ContigInfo, ReadWrapper>> {
	
	private final Graph<ContigInfo, ReadWrapper> graph;

	public InvalidateNotActiveNodes(Graph<ContigInfo, ReadWrapper> graph) {
		this.graph = graph;
	}

	@Override
	public void touch(Arc<ContigInfo, ReadWrapper> arc) {
		if(!arc.getLeft().isActive() || !arc.getRight().isActive()){
			graph.removeArc(arc);
		}
	}

}
